#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>

using namespace std;

int main(int argc, char const *argv[])
{
    stack<int> *bin, *hex;
    int n, i, t, p;
    cin >> t;
    
    bin = new stack<int>[t];
    hex = new stack<int>[t];

    for (i = 0; i < t; i++)
    {
        cin >> n;
        p = n;
        do bin[i].push(p % 2), p /= 2; while (p);
        p = n;
        do hex[i].push(p % 16), p /= 16; while (p);
    }

    for (i = 0; i < t; i++)
    {
        cout << (i ? "\n" : "")
            << "case #" 
            << i 
            << ":\n";
        
        while (!bin[i].empty()) cout << bin[i].top(), bin[i].pop();
        cout << " ";
        while (!hex[i].empty())
        {
            n = hex[i].top();
            hex[i].pop();

            if (n < 10) cout << n;
            else cout << (char)('A' + n % 10);  
        };
    }
    
    
    return 0;
}
